package org.cainiao.servlet.message.rocketmq.samples.consumer;

import lombok.RequiredArgsConstructor;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * ConsumerApplication
 */
@RequiredArgsConstructor
public class ConsumerApplication {

    private final RocketMQTemplate rocketMQTemplate;

    @Autowired
    private RocketMQTemplate extRocketMQTemplate;

    public void run() throws Exception {
        //This is an example of pull consumer using rocketMQTemplate.
        List<String> messages = rocketMQTemplate.receive(String.class);
        System.out.printf("receive from rocketMQTemplate, messages=%s %n", messages);

        //This is an example of pull consumer using extRocketMQTemplate.
        messages = extRocketMQTemplate.receive(String.class);
        System.out.printf("receive from extRocketMQTemplate, messages=%s %n", messages);
    }
}
